package com.stk.dots;

import java.util.Random;



class GraphicObject {
    private Coordinates _coordinates;
    private Speed _speed;
    private Life _life;
    private CircleColor _circleColor;
 
    public GraphicObject(Random random, int screenWidth, int screenHeight, int offSet) {
    	_coordinates = new Coordinates(random.nextInt(screenWidth - (offSet *2)) + offSet, random.nextInt(screenHeight - (offSet *2)) + offSet);
        _speed = new Speed(random.nextInt(1)+1);
    	_life = new Life(random.nextInt(500)+2400);
    	_circleColor = new CircleColor(255,255,255,255);	
    }
 
    public Coordinates getCoordinates() {
        return _coordinates;
    }
    
    public Speed getSpeed(){
    	return _speed;
    }
    
    public Life getLife(){
    	return _life;
    }
    
    public CircleColor getCircleColor(){
    	return _circleColor;
    }
    
    
 
    /**
     * Contains the coordinates of the graphic.
     */
    public class Coordinates {
        private int _x;
        private int _y;
        private int _radius = 1;
        
        public Coordinates (int x, int y){
        	_x = x;
        	_y = y;
        }
 
        public int getX() {
            return _x;
        }
 
        public void setX(int value) {
            _x = value;
        }
 
        public int getY() {
            return _y;
        }
 
        public void setY(int value) {
            _y = value;
        }
        
        public int getRadius() {
        	return _radius;
        }
        
        public void setRadius(int value) {
            _radius = value;
        }
 
        public String toString() {
            return "Coordinates: (" + _x + "/" + _y +  "/" + _radius +")";
        }
    }
    
    /**
     * Speed CLASS
     */
    public class Speed {
        public static final int INCREASE = 1;
        public static final int DECREASE = -1;
     
        private int _radiusSpeed = 1;
        private int _behaviour = INCREASE;
        
        public Speed(int radiusSpeed){
        	_radiusSpeed = radiusSpeed;
        }
        /**
         * @return the _behaviour
         */
        public int getBehaviour() {
            return _behaviour;
        }
     
        public void toggleBahaviour() {
            if (_behaviour == INCREASE) {
            	_behaviour = DECREASE;
            } else {
            	_behaviour = INCREASE;
            }
        }
     
        /**
         * @return the _radius
         */
        public int getRadiusSpeed() {
            return _radiusSpeed;
        }
     
        /**
         * @param speed the _x to set
         */
        public void setRadiusSpeed(int radiusSpeed) {
        	_radiusSpeed = radiusSpeed;
        }
        
        public String toString() {
            return "Speed: (" + _radiusSpeed + "/" + _behaviour +")";
        }
    }
    
    /**
     * Life CLASS
     */
    public class Life {
    	private boolean _active = true;
        private long _timeElapsed = 0;
        private int _lifeTime;
        
        public Life(int lifeTime){
        	_lifeTime = lifeTime;
        }
     
        public long getTimeElapsed (){
        	return _timeElapsed;
        }
        
        public void increaseTime(long elapsed) {
            _timeElapsed += elapsed;
        }
        
        public int getLifeTime () {
        	return _lifeTime;
        }
        
        public void setLifeTime(int life){
        	_lifeTime = life;
        }
        
        public boolean getActive(){
        	return _active;
        }
        
        public void setActive (boolean active){
        	_active = active;
        }
     
        public boolean checkLife(){
        	if (_timeElapsed > _lifeTime){
        		_active = false;
        	}else{
        		_active = true;
        	}
        	return _active;
        }
        
        public String toString() {
            return "Life: (" + _active + "/" + _timeElapsed +  "/" + _lifeTime +")";
        }
    }
    
    /**
     *	Class for colors and alpha (not useful in this one)
     */
    public class CircleColor{
    	private int _alpha;
    	private int _red;
    	private int _green;
    	private int _blue;
    	
    	public CircleColor(int a, int r, int g, int b){
    		_alpha = a;
    		_red = r;
    		_green = g;
    		_blue = b;
    	}
    	
    	public void setColors(int a, int r, int g, int b){
    		_alpha = a;
    		_red = r;
    		_green = g;
    		_blue = b;
    	}
    	
    	public int getAlpha(){
    		return _alpha;
    	}
    	
    	public int getRed(){
    		return _red;
    	}
    	
    	public int getGreen(){
    		return _green;
    	}
    	
    	public int getBlue(){
    		return _blue;
    	}
    	
    	public String toString() {
            return "Colors: (ALPHA:" + _alpha + "/ RED:" + _red +  "/ GREEN:" + _green +"/ BLUE:" + _blue +")";
        } 
    }
}
